using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.ComponentModel;

namespace Mdv.wssAddins.wss
{
    public class wssContentTypes : Model
    {
        #region Non-Designer Properties
        private List<wssContentType> _contentTypes;
        [Browsable(false)]
        public List<wssContentType> ContentTypes
        {
            get { return _contentTypes; }
        }
        private List<wssContentTypeRef> _contentTypeRefs;
        [Browsable(false)]
        public List<wssContentTypeRef> ContentTypeRefs
        {
            get { return _contentTypeRefs; }
        }
        #endregion
        public override string ToString()
        {
            return "ContentTypes";
        }
        public override void ConstructMap()
        {
        }
        public override void LoadChildren(XmlNode node)
        {
            foreach (XmlNode xn in node.ChildNodes)
            {
                switch (xn.Name)
                {
                    case "ContentTypeRef":
                        wssContentTypeRef contentTypeRef = new wssContentTypeRef();
                        contentTypeRef.Load(xn);
                        Children.Add(contentTypeRef);
                        break;
                    case "ContentType":
                        wssContentType contentType = new wssContentType();
                        contentType.Load(xn);
                        Children.Add(contentType);
                        break;
                }
            }
        }
        public wssContentTypes()
        {
            Actions = new List<Action>();
            Actions.Add(new Action("Add ContentType", this.AddContentType));
            Actions.Add(new Action("Add ContentTypeRef", this.AddContentTypeRef));
            Actions.Add(new Action("Delete", this.Delete));
        }
        public void AddContentType(ModelEventArgs e)
        {
            NodeAdded(new wssContentType(), "ContentType");
        }
        public void AddContentTypeRef(ModelEventArgs e)
        {
            NodeAdded(new wssContentTypeRef(), "ContentTypeRef");
        }
        public void Delete(ModelEventArgs e)
        {
            NodeDeleted("ContentTypes");
        }
    }
}